#!/bin/bash
if [ "$1" = "setup" ];then
    version=`lsb_release -a | awk -F: '/Release/{print $2}'`
    if [ $version == "18.04" ]; then
        rosversion="melodic" 
        OSversion="bionic"
    elif [ $version == "20.04" ]; then 
        rosversion="noetic"
        OSversion="focal"
    elif [ $version == "16.04" ]; then 
        rosversion="kinetic" 
        OSversion="xenial"
    fi

    sed -i "s/melodic/$rosversion/g"   ./src/inudev_ros_nodelet/include/config.h
    sed -i "s/melodic/$rosversion/g"   ./src/inudev_ros_nodelet/updateInuROSversion_Linux.pl
    sed -i "s/melodic/$rosversion/g"   ./src/inudev_ros_nodelet/src/inudev_ros_nodelet.cpp
 
    sed -i "s/bionic/$OSversion/g"   ./src/inudev_ros_nodelet/src/inudev_ros_nodelet.cpp

fi

catkin_make -DCMAKE_VERBOSE_MAKEFILE=OFF -DCMAKE_BUILD_TYPE=Release -DCATKIN_WHITELIST_PACKAGES="inudev_ros_nodelet"
